package ru.jexp.rcp.supply.lookandfeel;

import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;

public class JExpColorFactory {

	public static final String CELL_EDIT = "ru.jexp.rcp.supply.lookandfeel.celledit";

	private static JExpColorFactory INST;

	public Color createColor(String id) {
		return getColor(id);
	}

	private Color getColor(String id) {
		Color color = JFaceResources.getColorRegistry().get(id);
		if (color == null) {
			RGB rgb = createRgb(id);
			JFaceResources.getColorRegistry().put(CELL_EDIT, rgb);
			color = JFaceResources.getColorRegistry().get(CELL_EDIT);
		}
		return color;
	}

	private RGB createRgb(String id) {
		if (CELL_EDIT.equals(id)) {
			return new RGB(205, 245, 225);
		}
		throw new IllegalArgumentException("Color not register by key " + id);
	}

	public static JExpColorFactory getJExpColorfactory() {
		if (INST == null) {
			INST = new JExpColorFactory();
		}
		return INST;
	}

}
